package com.novax.ex.activity.provider.controller;

import com.novax.ex.activity.open.api.RankConfigApi;
import com.novax.ex.activity.open.model.response.RankConfigOuterResponse;
import com.novax.ex.activity.open.model.response.RankSubConfigResponse;
import com.novax.ex.activity.provider.service.RankConfigService;
import com.novax.ex.activity.provider.service.RankSubConfigService;
import com.novax.ex.common.enums.RankStatus;
import com.novax.ex.common.results.ReturnResult;
import com.novax.ex.common.util.CopyUtils;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import java.util.List;

@RestController
public class RankConfigController extends BaseActivityController implements RankConfigApi {

    @Resource
    private RankConfigService rankConfigService;
    @Resource
    private RankSubConfigService rankSubConfigService;

    @Override
    public ReturnResult<RankConfigOuterResponse> query() {
        return ReturnResult.success(CopyUtils.copyObject(rankConfigService.findOpenWithOutTime(), RankConfigOuterResponse.class));
    }

    @Override
    public ReturnResult<List<RankSubConfigResponse>> subListQuery(Long rankId) {
        return ReturnResult.success(CopyUtils.copyList(rankSubConfigService.subList(rankId, RankStatus.open.getStatus()), RankSubConfigResponse.class));
    }

}
